<template>
  <PageWrapper content-background>
    <BasicTable @register="registerTable">
      <template #toolbar>
        <a-button type="primary" @click="handleReloadCurrent">刷新当前页</a-button>
        <a-button type="primary" @click="handleReload">刷新并返回第一页</a-button>
      </template>
    </BasicTable>
  </PageWrapper>
</template>

<script setup lang="ts">
  import { PageWrapper } from '/@/components/Page';
  import { BasicTable, useTable } from '/@/components/Table';
  import { getBasicColumns } from './tableData';
  import { demoListApi } from '/@/api/demo/table';

  const [registerTable, { reload }] = useTable({
    title: '加载远程数据',
    // canResize: false,
    showTableSetting: true,
    api: demoListApi,
    columns: getBasicColumns(),
  });

  function handleReloadCurrent() {
    reload();
  }

  function handleReload() {
    reload({
      page: 1,
    });
  }
</script>

<style></style>
